const express = require('express')
const app = express();
const userInfomation = require('./utils/tool/userInfomation.js')


app.use(express.json());

app.listen(3000,()=>{
	console.log('端口:localhost:3000/启动');
});


// 获取商品列表的api
app.get('/products', (req, res) => {
  const result = userInfomation.getInfo('product');
  res.status(result.code).json(result);
});

// 获取用户信息列表的api
app.get('/users', (req, res) => {
  const result = userInfomation.getInfo('users');
  res.status(result.code).json(result);
});

// 创建用户的api
app.post('/users', (req, res) => {
  const result = userInfomation.saveUserInfo(req);
  res.status(result.code).json(result);
});


// 获取新闻列表的api
app.get('/getnews',(req,res)=>{
	const result = userInfomation.getInfo('getnews');
	res.status(result.code).json(result);
})